import { ipcMain } from 'electron'
import { addMessage, deleteMessage } from '../service/message'

/*
user-add-message 增加消息
user-delete-message 删除消息
*/

const messageController = () => {
  ipcMain.handle('message-add-message', async (event, data) => {
    try {
      const res = await addMessage(data)
      return res
    } catch (error) {
      return []
    }
  })
  ipcMain.handle('message-delete-message', async (event, id) => {
    try {
      const res = await deleteMessage(id)
      return res
    } catch (error) {
      return []
    }
  })
}

export default messageController
